import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsArray, IsNotEmpty, IsNumber, IsOptional, IsString } from 'class-validator';

// 查询账号
export class AccountListDto {
  @ApiProperty({ default: 1, description: '当前页' })
  @Type(() => Number)
  @IsNumber()
  page: number = 1;

  @ApiProperty({ default: 10, description: '查询条数' })
  @Type(() => Number)
  @IsNumber()
  size: number = 10;

  @ApiPropertyOptional({ description: '账号' })
  @IsOptional()
  @IsString()
  username?: string;

  @ApiPropertyOptional({ description: '名称' })
  @IsOptional()
  @IsString()
  nickname?: string;

  @ApiPropertyOptional({ description: '角色' })
  @IsOptional()
  @IsString()
  role?: string;
}

// 添加账号
export class CreateAccountDto {
  @ApiProperty({ description: '账号' })
  @IsNotEmpty()
  @IsString()
  username: string;

  @ApiProperty({ description: '密码' })
  @IsNotEmpty()
  @IsString()
  password: string;

  @ApiProperty({ description: '角色' })
  @IsNotEmpty()
  @IsString()
  role: string;

  @ApiProperty({ description: '状态' })
  @IsNotEmpty()
  @IsNumber()
  enableStatus: number;
}

// 更新账号
export class UpdateAccountDto {
  @ApiProperty({ description: '账号' })
  @IsNotEmpty()
  @IsString()
  id: string;

  @ApiProperty({ description: '账号' })
  @IsNotEmpty()
  @IsString()
  username: string;

  @ApiProperty({ description: '状态' })
  @IsNotEmpty()
  @IsNumber()
  enableStatus: number;
}

// 批量添加账号
export class BatchCreateAccountDto {
  @ApiProperty({ description: '账号列表' })
  @IsNotEmpty()
  @IsArray()
  list: CreateAccountDto[];
}
